package profile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;


public class ReadController extends AbstractController {
    private BoardMgr boardMgr;
    private String successView;

    public String getSuccessView() {
        return successView;
    }

    public void setSuccessView(String successView) {
        this.successView = successView;
    }  
    
    public BoardMgr getBoardMgr() {
        return boardMgr;
    }

    public void setBoardMgr(BoardMgr boardMgr) {
        this.boardMgr = boardMgr;
    }

    @Override
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        System.out.println("ReadController");
        
        int bno = Integer.parseInt(request.getParameter("bno"));
        
        ModelAndView mav = new ModelAndView();
        mav.setViewName(this.successView); 
        
        BoardDTO dto = boardMgr.read(bno);
        
        mav.addObject("dto", dto);
        
        return mav;
    }

    
}
